|
|
|
|
|
|
|
Figure 17.10.
Waiting for approval to
commit the transaction. |
|
|
|
|
|
|
|
|
If you choose No in this message box, Microsoft Jet reverses all the previously completed database operations between the Rollback and the BeginTrans statements. You can confirm this by clicking No, using Visdata or Data Manager to load the MULTIUS4.MDB database, and then inspecting the contents of the tables. |
|
|
|
|
| |
|
|
|
|
An SQL-Visual Basic script called MULTIUS4.SQV is included on the CD-ROM that accompanies this book. You can use this script with the SQL-VB program (see Days 13 and 15) to create a "clean" MULTIUS4.MDB file. After you run MULTIUS4.VBP once and answer Yes to commit the transaction, you might want to run the MULTIUS4.SQV script to refresh the database. |
|
|
|
|
|
|
|
|
|
|
Advantages and Limitations of Transactions |
|
|
|
|
|
|
|
|
The primary advantage of using transactions in your Visual Basic programs is that they can greatly increase the integrity of your data. You should use transactions whenever you are performing database operations that span more than one table or even operations that affect many records in a single table. A secondary advantage of using transactions is that they often increase the processing speed of Microsoft Jet. |
|
|
|
|
|
|
|
|
As useful as transactions are, there are still a few limitations. First, some database formats might not support transactions (for example, Paradox files do not support transactions). You can check for transaction support by checking the Transactions property of the database. If transactions are not supported, Microsoft Jet ignores the transaction statements in your code; you do not receive an error message. Some Dynasets might not support transactions, depending on how they are constructed. Usually, sets that are the result of SQL JOIN and WHERE clauses or result sets that contain data from attached tables do not support transactions. |
|
|
|
|
|
|
|
|
Transaction operations are kept on the local workstation in a temporary directory (the one pointed to by the TEMP environment variable). If you run out of available space on the TEMP drive, you'll receive error 2004. You can trap for this error. The only solution is to make more disk space available or to reduce the number of database operations between the BeginTrans and the CommitTrans statements. |
|
|
|
|
|